package com.quanshu.exchange.ui.gui.profile.member;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.widget.LinearLayout;

import com.quanshu.exchange.R;
import com.quanshu.exchange.support.utils.RxViewHelper;
import com.quanshu.exchange.ui.base.BaseActivity;
import com.quanshu.exchange.ui.gui.profile.order_fragment.OrderAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 会员订单列表
 */
public class MemberBindListActivity extends BaseActivity {

    @BindView(R.id.back)
    LinearLayout back;
    @BindView(R.id.order_tabLayout)
    TabLayout orderTabLayout;
    @BindView(R.id.order_viewPager)
    ViewPager orderViewPager;

    private List<String> titleList;//标题集合
    private List<Fragment> fragments;//页面集合
    private OrderAdapter orderAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_member_bind_list);
        ButterKnife.bind(this);
        initView();
        initListener();
    }

    private void initView() {
        titleList = new ArrayList<>();
        titleList.add("会员已绑定用户数");
        titleList.add("会员直接已绑定用户数");
        titleList.add("会员已绑定用户推荐用户绑定数");

        fragments = new ArrayList<>();
        fragments.add(MemberBindFragment.newInstance(3));
        fragments.add(MemberBindFragment.newInstance(2));
        fragments.add(MemberBindFragment.newInstance(1));

        orderAdapter = new OrderAdapter(getSupportFragmentManager(), titleList, fragments);
        orderViewPager.setAdapter(orderAdapter);
        orderTabLayout.setupWithViewPager(orderViewPager);
        orderViewPager.setCurrentItem(0);
    }

    private void initListener() {
        RxViewHelper.getInstance().clicks(back, aVoid -> finish());
    }

}
